
////.........当前代码为程序自动生成,请勿手动修改.......
////.........一维数组分割符=[◆ ⧫, ，=]........_二维数组分割符=[✚ + @ &  ; ；]
////.........字段类型添加参数..使用问号分割....(?f/?find)=(搜索字段).....
////.........0行0列..可以填写父类的名字...也可添加参数.(?f)=(显示字段索引).....
////.........表名.说明.....名字与后缀中文的分隔符....'&', '$', '@'.......【ResCfg@资源表】
////.........覆盖表.说明.......表名中间增加一个字段.......【ResCfg@art07@资源表】


using System;
using System.Collections.Generic;
using System.Linq;
using CSUtils;
using CSUtils.WeProtoCore;
//using UnityEngine;
using TripleJumpRoleCfg;
/// <summary>
/// 角色
/// </summary>
namespace TripleJumpRoleCfg {
	/// <summary>
	/// 贸易角色
	/// </summary>
	public partial class CfgTJumpRole: CExcelCfg {

		public const string _tag = "[TripleJumpRoleCfg@角色.xlsx/CfgTJumpRole@贸易角色]";
		/// <summary>
		/// 
		/// </summary>
		public int id { get; protected set; }
		/// <summary>
		/// 常亮
		/// </summary>
		public string Const { get; protected set; }
		/// <summary>
		/// 角色类型
		/// </summary>
		public CMPart.ETRoleType type { get; protected set; }
		/// <summary>
		/// 显示名字Key
		/// </summary>
		public string showNameKey { get; protected set; }
		/// <summary>
		/// 升级显示文字Key
		/// </summary>
		public string upgradeNameKey { get; protected set; }
		/// <summary>
		/// tag
		/// </summary>
		public string tag { get; protected set; }
		/// <summary>
		/// 资源路径类型/icon路径类型
		/// </summary>
		public string artPath { get; protected set; }
		/// <summary>
		/// 角色模型大小
		/// </summary>
		public float roleModelSize { get; protected set; }
		/// <summary>
		/// 唯一资源路径/icon路径
		/// </summary>
		public string artName { get; protected set; }
		/// <summary>
		/// 是否需要添加钢体碰撞检测
		/// </summary>
		public bool isNeedColliderCheck { get; protected set; }
		/// <summary>
		/// 是否需要Nav询路
		/// </summary>
		public bool isNeedNavMove { get; protected set; }
		/// <summary>
		/// 移动速度
		/// </summary>
		public C4Curve moveSpeed { get; protected set; }
		/// <summary>
		/// 角色半径
		/// </summary>
		public float roleRadius { get; protected set; }
		/// <summary>
		/// 下一个id字段
		/// </summary>
		public CfgTJumpRole _nextCfg { get; protected set; }


		#region----常量字段...constant----------------------------------------------
		public static CfgTJumpRole firstPlayer => CfgTJumpRole.Get(id_firstPlayer);//常量.........firstPlayer
		public static int id_firstPlayer { get; private set; }= 30001;//firstPlayer
		public static CfgTJumpRole 收银员 => CfgTJumpRole.Get(id_收银员);//常量.........收银员
		public static int id_收银员 { get; private set; }= 30002;//收银员
		public static CfgTJumpRole 清理工 => CfgTJumpRole.Get(id_清理工);//常量.........清理工
		public static int id_清理工 { get; private set; }= 30003;//清理工
		public static CfgTJumpRole 搬运工 => CfgTJumpRole.Get(id_搬运工);//常量.........搬运工
		public static int id_搬运工 { get; private set; }= 30004;//搬运工

		#endregion---常量字段...constant----------------------------------------------------




		public static CfgTJumpRole[] arr{
			get {
				if (_arr == null) {
					__InitParent();
					_arr = id_cfgDic.Values.ToArray();;
				}
				return _arr;
			}
		}
		static CfgTJumpRole[] _arr;
		public static CfgTJumpRole firstCfg{ get; protected set; }
		public static Dictionary<int,CfgTJumpRole> GetDic(){
			return id_cfgDic;
		}
		protected static Dictionary<int,CfgTJumpRole> id_cfgDic = new Dictionary<int, CfgTJumpRole>();
		public CfgTJumpRole(){}
		public CfgTJumpRole( int id, string Const, CMPart.ETRoleType type, string showNameKey, string upgradeNameKey, string tag, string artPath, float roleModelSize, string artName, bool isNeedColliderCheck, bool isNeedNavMove, C4Curve moveSpeed, float roleRadius){
			this.id = id;
			this.Const = Const;
			this.type = type;
			this.showNameKey = showNameKey;
			this.upgradeNameKey = upgradeNameKey;
			this.tag = tag;
			this.artPath = artPath;
			this.roleModelSize = roleModelSize;
			this.artName = artName;
			this.isNeedColliderCheck = isNeedColliderCheck;
			this.isNeedNavMove = isNeedNavMove;
			this.moveSpeed = moveSpeed;
			this.roleRadius = roleRadius;
			__InitC(this);
			TripleJumpRoleCfg.CfgTJumpRole.id_cfgDic[id] = this;
		}
		static CfgTJumpRole () {
			__InitParent();
		}
		internal static void __InitParent() {
			__InitSub();
		}
		static bool __isInit;
		public static void __InitSub() {
			if(__isInit)return;
			__isInit = true;
			//id_cfgDic.Clear();
			new CfgTJumpRole(30001, @"firstPlayer", (CMPart.ETRoleType)0, @"", @"", @"Player", @"TripleJump/Model/10_Role/-2_10_1_0_cattle2.prefab", 2f, @"", true, false, new CSUtils.C4Curve(2.4f), 0.1f);
			new CfgTJumpRole(30002, @"收银员", (CMPart.ETRoleType)3, @"tName_Cashier", @"", @"Worker", @"TripleJump/Model/10_Role/-2_10_1_0_cattle2.prefab", 2f, @"", true, true, new CSUtils.C4Curve(1.8f), 0.1f);
			new CfgTJumpRole(30003, @"清理工", (CMPart.ETRoleType)1, @"tName_CleanWorker", @"t提速", @"Clean", @"TripleJump/Model/10_Role/-2_10_1_0_cattle2.prefab", 2f, @"", true, true, new CSUtils.C4Curve(1.2f,2.4f,3,0.25f), 0.1f);
			new CfgTJumpRole(30004, @"搬运工", (CMPart.ETRoleType)2, @"tName_PorterWorker", @"t提速", @"Worker", @"TripleJump/Model/10_Role/-2_10_1_0_cattle2.prefab", 2f, @"", true, true, new CSUtils.C4Curve(1.2f,2.4f,3,0.25f), 0.1f);
			//TripleJumpRoleCfg.CfgTJumpRole._arr = TripleJumpRoleCfg.CfgTJumpRole.id_cfgDic.Values.ToArray();
		}
		public CfgTJumpRole Clone(CfgTJumpRole cfg = null) => CopyTo(cfg);
		bool _isClone;
		public CfgTJumpRole CopyTo(CfgTJumpRole cfg = null){
			if (cfg == null) {
			   cfg = new CfgTJumpRole();
			   cfg._isClone = true;
			} else {
			   if (cfg._isClone == false) {
			      CLog.Ex(_tag,$"原始数据..无法修改....{_tag}");
			      return null;
			   }
			}
			cfg.id = id;
			cfg.Const = Const;
			cfg.type = type;
			cfg.showNameKey = showNameKey;
			cfg.upgradeNameKey = upgradeNameKey;
			cfg.tag = tag;
			cfg.artPath = artPath;
			cfg.roleModelSize = roleModelSize;
			cfg.artName = artName;
			cfg.isNeedColliderCheck = isNeedColliderCheck;
			cfg.isNeedNavMove = isNeedNavMove;
			cfg.moveSpeed = moveSpeed;
			cfg.roleRadius = roleRadius;
			return cfg;
		}
		public virtual object this[int fieldIndex]{
			set{
				if (_isClone == false) {
					CLog.E(_tag,$"bu不是克隆表格....无法设置...fieldIndex={fieldIndex}.....{value}");
					return;
				}
				try{
					switch (fieldIndex) {
						case 1: //ECSType.eint
							id = Convert.ToInt32(value);
							break;
						case 3: //ECSType.estring
							Const = Convert.ToString(value);
							break;
						case 8: //ECSType.eenum
							type = (CMPart.ETRoleType)Convert.ToInt32(value);
							break;
						case 10: //ECSType.estring
							showNameKey = Convert.ToString(value);
							break;
						case 15: //ECSType.estring
							upgradeNameKey = Convert.ToString(value);
							break;
						case 22: //ECSType.estring
							tag = Convert.ToString(value);
							break;
						case 24: //ECSType.estring
							artPath = Convert.ToString(value);
							break;
						case 35: //ECSType.efloat
							roleModelSize = Convert.ToSingle(value);
							break;
						case 45: //ECSType.estring
							artName = Convert.ToString(value);
							break;
						case 46: //ECSType.ebool
							isNeedColliderCheck = Convert.ToBoolean(value);
							break;
						case 52: //ECSType.ebool
							isNeedNavMove = Convert.ToBoolean(value);
							break;
						case 72: //ECSType.eWeCustomType
							moveSpeed = (C4Curve)value;
							break;
						case 83: //ECSType.efloat
							roleRadius = Convert.ToSingle(value);
							break;
					}
				} catch(Exception ex){
					var st = new System.Diagnostics.StackTrace(true);
					    CLog.Ex($"CfgTJumpRole",$"设置数据错误......index={fieldIndex}.....value={value}", ex, st);
				}
			}
		}
		public static class Field {
			public static void ResetConst(string fieldName, int value) {
				switch (fieldName) {
					case "firstPlayer": //---firstPlayer
						id_firstPlayer = value;
						break;
					case "收银员": //---收银员
						id_收银员 = value;
						break;
					case "清理工": //---清理工
						id_清理工 = value;
						break;
					case "搬运工": //---搬运工
						id_搬运工 = value;
						break;
				}
			}
		}

        static CfgTJumpRole __upCfg;
        static void __InitC(CfgTJumpRole cfg) {
            if (firstCfg == null) {
                firstCfg = cfg;
            }
            if (__upCfg != null) {
                __upCfg._nextCfg = cfg; 
            }
            __upCfg = cfg;
        }

		public class Find { //#region MyRegion-----Excel生成的表格类， 除了float类型字段，其他所有字段都能进行查询---

            #region MyRegion------[Const..常亮..]...除了float类型字段，其他所有字段都能进行查询-----
            public static CfgTJumpRole GetCfg_Const(string key) {
                _InitAll_Const();
                _ConstDic.TryGetValue(key, out var list);
                if (list != null && list.Count > 0) {
                    return list[0];
                }
                return null;
            }
    
            public static List<CfgTJumpRole> GetCfgList_Const(string key) {
                _InitAll_Const();
                _ConstDic.TryGetValue(key, out var list);
                return list;
            }
    
            static Dictionary<string, List<CfgTJumpRole>> _ConstDic = new Dictionary<string, List<CfgTJumpRole>>();
    
            static void _InitAll_Const() {
                if (_ConstDic.Count > 0) {
                    return;
                }
                var _arr = arr;
                for (int i2 = 0; i2 < _arr.Length; i2++) {
                    var cfg = _arr[i2];
                    AddData(cfg.Const, cfg);
                }
                void AddData(string key, CfgTJumpRole cfg){
                    if (_ConstDic.TryGetValue(key, out var list) == false) {
                        list = new List<CfgTJumpRole>();
                        _ConstDic[key] = list;
                    }
                    list.Add(cfg);
                }
            }
            #endregion MyRegion------[Const..常亮..]...除了float类型字段，其他所有字段都能进行查询-----

            #region MyRegion------[type..角色类型..]...除了float类型字段，其他所有字段都能进行查询-----
            public static CfgTJumpRole GetCfg_type(CMPart.ETRoleType key) {
                _InitAll_type();
                _typeDic.TryGetValue(key, out var list);
                if (list != null && list.Count > 0) {
                    return list[0];
                }
                return null;
            }
    
            public static List<CfgTJumpRole> GetCfgList_type(CMPart.ETRoleType key) {
                _InitAll_type();
                _typeDic.TryGetValue(key, out var list);
                return list;
            }
    
            static Dictionary<CMPart.ETRoleType, List<CfgTJumpRole>> _typeDic = new Dictionary<CMPart.ETRoleType, List<CfgTJumpRole>>();
    
            static void _InitAll_type() {
                if (_typeDic.Count > 0) {
                    return;
                }
                var _arr = arr;
                for (int i2 = 0; i2 < _arr.Length; i2++) {
                    var cfg = _arr[i2];
                    AddData(cfg.type, cfg);
                }
                void AddData(CMPart.ETRoleType key, CfgTJumpRole cfg){
                    if (_typeDic.TryGetValue(key, out var list) == false) {
                        list = new List<CfgTJumpRole>();
                        _typeDic[key] = list;
                    }
                    list.Add(cfg);
                }
            }
            #endregion MyRegion------[type..角色类型..]...除了float类型字段，其他所有字段都能进行查询-----
		}//#endregion MyRegion----Excel生成的表格类， 除了float类型字段，其他所有字段都能进行查询-----
		public static CfgTJumpRole Get(int id, string noExistErrorLog ="", bool isForceGet = false) {
			if(id_cfgDic.Count == 0) { __InitParent();}
			if(id_cfgDic.TryGetValue(id, out var cfg)){
				return cfg;
			}
			if(noExistErrorLog!=null) { CLog.E(_tag,$"加载表格失败..id不存在......id={id}.......{noExistErrorLog}");}
			if(isForceGet) { return arr[id.GetHashCode() % arr.Length]; }
			return null;
		}
		public static bool IsHave(int id) {
			if(id_cfgDic.Count == 0) { __InitParent();}
			return id_cfgDic.ContainsKey(id);
		}
		public static void _ClearAll(bool isReload = false) {
		    firstCfg = null;
		    _arr = null;
		    id_cfgDic.Clear();
		    if (isReload) { __isInit = false; }
		}
		public override string ToString() {
		    return $"CfgTJumpRole.{id}/{Const}";
		}
	}

}